import json

# 加载原始数据
with open('../datasets/annotations/val.json', 'r') as f:
    data = json.load(f)

# 合并类别
new_categories = [
    {
        "id": 0,
        "name": "table",
        "supercategory": "data-table"
    }
]

# 更新标注的类别ID，改为仅有一个table类别
for annotation in data['annotations']:
    if annotation['category_id'] in [0, 1]:
        annotation['category_id'] = 0

# 更新数据中的类别
data['categories'] = new_categories

# 保存修改后的数据
with open('../datasets/annotations/modified_val.json', 'w') as f:
    json.dump(data, f, indent=4)
